package com.company.dcm.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.company.dcm.entity.R_ClothSheet;
import com.company.dcm.entity.R_ClothSheetDetail;
import com.company.dcm.mapper.R_ClothSheetDetailMapper;
import com.company.dcm.mapper.R_ClothSheetMapper;
import com.company.dcm.service.R_ClothSheetDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class R_ClothSheetDetailServiceImpl extends ServiceImpl<R_ClothSheetDetailMapper, R_ClothSheetDetail> implements R_ClothSheetDetailService {
    @Autowired
    private R_ClothSheetDetailMapper r_clothSheetDetailMapper;

    @Override
    public R_ClothSheetDetail getR_ClothSheetDetailByDeviceCodeAndSerialNo(String deviceCode, String serialNo) {
        List<R_ClothSheetDetail> list = r_clothSheetDetailMapper.selectList(new LambdaQueryWrapper<R_ClothSheetDetail>()
                .eq(R_ClothSheetDetail::getDeviceCode,deviceCode)
                .eq(R_ClothSheetDetail::getSerialNo,serialNo)
                .orderBy(true,false, R_ClothSheetDetail::getId)
                .last("limit 1"));
        if(list.size()>0)return list.get(0);
        else return null;
    }
}
